﻿using System;
using System.Collections;
using System.Text;
using System.Configuration;
using System.Xml;

namespace YEA.Infrastructure.Gateway.Config
{
    public class ConnectionSection : ConfigurationSection
    {
        [ConfigurationProperty("ConnectionList", IsRequired = true)]
        public ConnectionCollection ConnectionList
        {
            get
            {
                return (ConnectionCollection)this["ConnectionList"];
            }
        }

        [ConfigurationProperty("PublisherList", IsRequired = false)]
        public PublisherCollection PublisherList
        {
            get
            {
                return (PublisherCollection)this["PublisherList"];
            }
        }

        [ConfigurationProperty("SyncReceiverList", IsRequired = false)]
        public SyncReceiverCollection SyncReceiverList
        {
            get
            {
                return (SyncReceiverCollection)this["SyncReceiverList"];
            }
        }
        [ConfigurationProperty("AsyncReceiverList",IsRequired = false)]
        public AsyncReceiverCollection AsyncReceiverList
        {
            get
            {
                return (AsyncReceiverCollection)this["AsyncReceiverList"];
            }
        }
    }

    public class ConnectionFactory : ConfigurationElement
    {
        [ConfigurationProperty("name", DefaultValue = "", IsRequired = true)]
        public string Name
        {
            get { return (string)this["name"]; }
            set { this["name"] = value; }
        }
        [ConfigurationProperty("server", DefaultValue = "", IsRequired = true)]
        public string Server
        {
            get { return (string)this["server"]; }
            set { this["server"] = value; }
        }
        [ConfigurationProperty("username", DefaultValue = "guest", IsRequired = false)]
        public string UserName
        {
            get { return (string)this["username"]; }
            set { this["username"] = value; }
        }
        [ConfigurationProperty("password", DefaultValue = "guest", IsRequired = false)]
        public string Password
        {
            get { return (string)this["password"]; }
            set { this["password"] = value; }
        }
    }
    public class Publisher : ConfigurationElement
    {
        [ConfigurationProperty("name", DefaultValue = "", IsRequired = true)]
        public string Name
        {
            get { return (string)this["name"]; }
            set { this["name"] = value; }
        }
        [ConfigurationProperty("connection", DefaultValue = "", IsRequired = true)]
        public string Connection
        {
            get { return (string)this["connection"]; }
            set { this["connection"] = value; }
        }

        [ConfigurationProperty("exchange", DefaultValue = "", IsRequired = true)]
        public string Exchange
        {
            get { return (string)this["exchange"]; }
            set { this["exchange"] = value; }
        }
        [ConfigurationProperty("mandatory", DefaultValue = false, IsRequired = false)]
        public bool Mandatory
        {
            get { return (bool)this["mandatory"]; }
            set { this["mandatory"] = value; }
        }
        [ConfigurationProperty("immediate", DefaultValue = false, IsRequired = false)]
        public bool Immediate
        {
            get { return (bool)this["immediate"]; }
            set { this["immediate"] = value; }
        }
    }
    public class SyncReceiver : ConfigurationElement
    {
        [ConfigurationProperty("name", DefaultValue = "", IsRequired = true)]
        public string Name
        {
            get { return (string)this["name"]; }
            set { this["name"] = value; }
        }
        [ConfigurationProperty("connection", DefaultValue = "", IsRequired = true)]
        public string Connection
        {
            get { return (string)this["connection"]; }
            set { this["connection"] = value; }
        }
        [ConfigurationProperty("queue", DefaultValue = "", IsRequired = true)]
        public string Queue
        {
            get { return (string)this["queue"]; }
            set { this["queue"] = value; }
        }
    }
    public class AsyncReceiver : ConfigurationElement
    {
        [ConfigurationProperty("name", DefaultValue = "", IsRequired = true)]
        public string Name
        {
            get { return (string)this["name"]; }
            set { this["name"] = value; }
        }
        [ConfigurationProperty("connection", DefaultValue = "", IsRequired = true)]
        public string Connection
        {
            get { return (string)this["connection"]; }
            set { this["connection"] = value; }
        }
        [ConfigurationProperty("queue", DefaultValue = "", IsRequired = true)]
        public string Queue
        {
            get { return (string)this["queue"]; }
            set { this["queue"] = value; }
        }
        [ConfigurationProperty("maxthreads", DefaultValue = 1, IsRequired = false)]
        public int MaxThreads
        {
            get { return (int)this["maxthreads"]; }
            set { this["maxthreads"] = value; }
        }
    }

}
